<template>
  <div class="goods-list">
    <!--对接真实接口:key使用ID来区别-->
    <div class="panel" v-if="list" v-for="(item,index) in list" @click="goDetail(item.id)" :key="index">
      <div class="img">
        <span>券￥{{item.ticket}}</span>
        <img v-lazy="item.img" :key="item.img"/>
      </div>
      <div class="con">
        <div class="tit">{{item.title}}</div>
        <div class="price">
          <span><em class="new">￥{{item.price}}</em>券后</span>
          <span class="xl">销量 151</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      list: Array
    },
    data() {
      return {}
    },
    methods: {
      goDetail (id) {
      	this.$emit('goDetail',id);
      }
    }
  }
</script>

<style lang="less">
  @import '../../common/less/variable';
  .goods-list{
    display: flex;
    flex-wrap: wrap;
    padding: 0 10px;
    justify-content: space-between;
    .panel{
      width: 49%;
      box-sizing: border-box;
      margin: 5px 0;
      .img{
        background-color: #ddd;
        position: relative;
        width: 100%;
        height: 0;
        padding-top: 100%;
        span{
          display: inline-block;
          position: absolute;
          bottom: 0;
          right: 0;
          z-index: 2;
          background-color: @color-theme-d;
          background: -webkit-gradient(linear,0 0,100% 100%,from(@color-theme-d),to(@color-theme));
          font-size: 12px;
          padding: 2px 5px;
          border-radius: 2px;
          color: @color-text-w;
        }
        // border:1px solid @color-border;
        img{
          z-index: 1;
          position: absolute;
          left: 0;
          top: 0;
          width: 100%;
          height: 100%;
        }
        img[lazy=loading] {
          width: 60px;
          height: 60px;
          left: 50%;
          top: 50%;
          margin-top: -30px;
          margin-left: -30px;
        }
        img[lazy=error] {

        }
      }
      .con{
        flex: 1;
        background-color: #fff;
        padding: 10px 10px;
        .tit{
          font-size: @font-size-medium;
          height: 36px;
          line-height: 1.4em;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
        }
        .price{
          display: flex;
          margin: 7px 0;
          font-size: @font-size-small;
          color: @color-text-h;
          justify-content: space-between;
          span{
            display: inline-block;
            line-height: 16px;
            vertical-align: bottom;
            height: 16px;
          }
          .new{
            font-size: @font-size-medium-x;
            font-style: normal;
            font-weight: bold;
            color: @color-text-t;
            margin-right: 2px;
          }
          .xl{
            margin-top: 2px;
          }
        }
      }
    }
  }
</style>
